package cn.edu.jxau.test;

import java.util.Arrays;
import java.util.Objects;

public class Main {

	public static void main(String[] args) {

		foo(15);
	}

	public static void foo(int sum) {

		// 1.参数校验 //
		if (sum <= 0) {
			throw new IllegalArgumentException("参数sum必须是正数");
		}
		int small = 1;
		int big = 2;
		while (small < big) {
			int s = sum(small, big);
			if (s < sum) {
				big++;
			} else if (s > sum) {
				small++;
			} else {
				System.out.println(small + "\t" + big);
				small++;
			}
		}
	}

	private static int sum(int small, int big) {
		int sum = 0;
		for (int i = small; i <= big; i++) {
			sum += i;
		}
		return sum;
	}
}